﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BiliBiliCSharpStudy.old {
    /**
     * add at 2022.08.21
     * 刘铁锰
     * 有个同学问我，“三点水”加“来”读作“lai”；“三点水”加“去”读作什么？
     * 我想了好久，回到宿舍，室友问我在思考什么，我说了；然后室友说，“三点水”加“去”不是法律的法吗？
     * 我恍然，原来我陷入了思维误区!
     */
    class SentenceDemo02 {
        public static void demo() {
            //test1();
            //test2();
            test3();
        }

        // 使用switch
        public static void test3() {
            int score = 95;
            // 快捷键: sw tab tab
            switch (score / 10) {
                case 10:
                    if (score == 100) {
                        goto case 8;
                    } else {
                        goto default;
                    }
                case 8:
                case 9:
                    Console.WriteLine("A");
                    break;
                case 6:
                case 7:
                    Console.WriteLine("B");
                    break;
                case 4:
                case 5:
                    Console.WriteLine("C");
                    break;
                case 0:
                case 1:
                case 2:
                case 3:
                    Console.WriteLine("D");
                    break;
                default:
                    Console.WriteLine("Error!");
                    break;
            }
        }

        // if else if 语句
        // 将test1中的逻辑变得更加清晰
        public static void test2() {
            int score = 95;
            if (score >= 80 && score <= 100) {
                Console.WriteLine("A");
            } else if (score >= 60) {
                Console.WriteLine("B");
            } else if (score >= 40) {
                Console.WriteLine("C");
            } else if (score >= 0) {
                Console.WriteLine("D");
            } else {
                Console.WriteLine("input error!");
            }
        }

        // if 语句
        public static void test1() {
            int score = 59;
            if (score >= 0 && score <= 100) {
                if (score >= 60) {
                    if (score >= 80) {
                        Console.WriteLine("A");
                    } else {
                        Console.WriteLine("B");
                    }
                } else {
                    if (score >= 40) {
                        Console.WriteLine("C");
                    } else {
                        Console.WriteLine("D");
                    }
                }
            } else {
                Console.WriteLine("input error!");
            }
        }

    }
}
